<%@ page language="java"
         import="com.ruohi.manage.DBType,com.ruohi.manage.PoolManager,com.ruohi.util.common.CommonDate,com.ruohi.util.common.CommonForm,com.ruohi.util.common.CommonString"
         pageEncoding="UTF-8" %>
<%@ page import="com.ruohi.util.common.Env" %>
<%@ page import="com.ruohi.util.dbutil.DBHelper" %>
<%@ page import="java.sql.Connection" %>
<%@ page import="java.util.ArrayList" %>
<%@ page import="java.util.HashMap" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%
    Connection connection = null;
    String tablePrefix = Env.getInstance().getProperty("table_prefix");
    DBHelper dbHelper = DBHelper.getInstance();
    Map model = new HashMap();
    String tableName = " gift_job ";
    try {
        List<Map> brandList = (ArrayList) application.getAttribute("giftBrandList");
        connection = PoolManager.getConnection(DBType.getDBTypeByEnum("106013"));
        String id = CommonString.getFormatPara(request.getParameter("id"));
        String channelUUID = CommonString.getFormatPara(request.getParameter("channel_uuid"));
        if (null != id && !"".equals(id)) {
            model = dbHelper.getMap(" select * from " + tableName + " where uuid = ? ", new Object[]{id}, connection);
        }
        if ("".equals(channelUUID) && null != model) {
            channelUUID = (String) model.get("channel_uuid");
        }
%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title><%=Env.getInstance().getProperty("project_name") %>
    </title>
    <link href="/plugin/ui/ligerUI/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css"/>
    <link href="/plugin/ui/ligerUI/ligerUI/skins/Gray/css/all.css" rel="stylesheet" type="text/css"/>
    <link href="/plugin/ui/ligerUI/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css"/>
    <link href="/backend/style/style.css" rel="stylesheet" type="text/css"/>
    <script src="/plugin/jquery/jquery.min.js" type="text/javascript"></script>
    <script type="text/javascript" charset="utf-8" src="/plugin/editor/ueditor/editor_config.js"></script>
    <script type="text/javascript" charset="utf-8" src="/plugin/editor/ueditor/editor_all_min.js"></script>
    <link rel="stylesheet" type="text/css" href="/plugin/editor/ueditor/themes/default/ueditor.css"/>
</head>

<body style="margin: 0;padding: 0; overflow-x: hidden; overflow-y: auto; ">
<form name="theform" id="theform" action="/backend/action/crud.jsp?enumNo=106013">
    <div class="formDiv">
        <div class="formLeft">标<span class="span2"></span>题</div>
        <div class="formRight">
            <input type="text" dataType='Require' msg='标题不能为空！' class="jr_text" name="zd_title" id="zd_title"
                   value="<%=CommonString.getFormatPara(model.get("title")) %>"/>
        </div>
        <div style="clear:left;"></div>
        <div class="formLeft">发布日期</div>
        <div class="formRight" style="width: 190px;">
            <%
                String nowDate = CommonDate.getFormatDate("yyyy-MM-dd HH:mm", model.get("pub_date"));
                if ("".equals(nowDate)) {
                    nowDate = CommonDate.getToday("yyyy-MM-dd HH:mm:ss");
                }
            %>
            <input type="text" class="Wdate" onclick="WdatePicker({dateFmt:'yyyy-MM-dd HH:mm:ss'});" name="zd_pub_date"
                   id="zd_pub_date" value="<%=nowDate %>"/>
        </div>
        <div style="clear:left;"></div>
        <div class="formLeft">新闻内容</div>
        <div class="formRight" style="height: 300px; text-align: left;">
            <script type="text/plain" id="editor_content"
                    style="width:650px; height:200px;"><%=CommonString.getFormatPara(model.get("content")) %>
            </script>
            <
            input
            type = "hidden"
            dataType = 'Require'
            msg = '新闻内容不能为空！'
            name = "zd_content"
            id = "zd_content"
            value = "" / >
                < /div>
                < div
            style = "clear:left;" > < /div>
                < div
            class
            = "formLeft" > 是否发布 < /div>
                < div
            class
            = "formRight"
            style = "width: 120px;" > <%=CommonForm.createIsRadio(CommonString.getFormatPara(model.get("is_show")),"zd_is_show") %> < /div>
                < div
            class
            = "formLeft" > 是否置顶 < /div>
                < div
            class
            = "formRight"
            style = "width: 120px;" > <%=CommonForm.createIsRadio(CommonString.getFormatPara(model.get("is_top")).equals("")?"0":CommonString.getFormatPara(model.get("is_top")),"zd_is_top") %> < /div>
                < div
            class
            = "formLeft" > 点击次数 < /div>
                < div
            class
            = "formRight"
            style = "text-align: left;width:120px" >
                < input
            type = "text"
            class
            = "jr_text"
            style = "width: 100px;"
            name = "zd_view_count"
            id = "zd_view_count"
            value = "<%=CommonString.getFormatPara(model.get("view_count")) %>" / >
                < /div>
                < /div>
                < div
            style = "clear: left;" > < /div>
                < input
            type = "hidden"
            name = "tableName"
            id = "tableName"
            value = "<%=tableName %>" / >
                < input
            type = "hidden"
            name = "zd_id"
            id = "zd_id"
            value = "<%=CommonString.getFormatPara(model.get("id")) %>" / >
                < input
            type = "hidden"
            name = "zd_channel_uuid"
            id = "zd_channel_uuid"
            value = "<%=channelUUID %>" / >
                < /form>
                < /body>
                < /html>
                < script
            type = "text/javascript"
            src = "/plugin/jquery/jquery.form.js" ></script>
            <script src="/plugin/ui/ligerUI/ligerUI/js/ligerui.min.js" type="text/javascript"></script>
            <script src="/plugin/date/My97DatePicker/WdatePicker.js" type="text/javascript"></script>
            <script src="/backend/scripts/common.js" prefix="<%=tablePrefix %>" type="text/javascript"></script>
            <script src="/plugin/validator/wofoshan/validator.min.js" type="text/javascript"></script>
            <script type="text/javascript">
                function doSub() {
                    var rs = Validator.Validate(document.getElementById("theform"), 1);
                    if (rs) {
                        jQuery("#theform").ajaxSubmit({
                            type: "POST",
                            async: false,
                            success: function (data) {
                                var rs = parseInt(jQuery.trim(data), 10);
                                if (rs > 0) {
                                    jrSuccess("保存成功！");
                                    <%
                                    if("".equals(id)){
                                        %>
                                    window.location.reload();
                                    <%
                                }
                                %>
                                }
                            }
                        });
                    }
                }

                var ue_content = new baidu.editor.ui.Editor({
                    textarea: 'zd_content',
                    autoHeightEnabled: false,
                    minFrameHeight: 220
                });
                ue_content.render('editor_content');
                ue_content.addListener("selectionchange", function () {
                    var state_content = ue_content.queryCommandState("source");
                    document.getElementById("zd_content").value = ue_content.getContent();
                });
                document.getElementById("zd_content").value = ue_content.getContent();
            </script>
<%
    } catch (Exception e) {
        e.printStackTrace();
    } finally {
        dbHelper.freeConnection(connection);
    }
%>